class <%= model_controller_class_name %>Controller < ApplicationController
  # Be sure to include AuthenticationSystem in Application Controller instead
  include AuthenticatedSystem

  # render new.rhtml
  def new
  end

  def create
    @<%= file_name %> = <%= class_name %>.new(params[:<%= file_name %>])
    @<%= file_name %>.save!
    self.current_<%= file_name %> = @<%= file_name %>
    redirect_back_or_default('/')
    flash[:notice] = "Thanks for signing up!"
  rescue ActiveRecord::RecordInvalid
    render :action => 'new'
  end
<% if options[:include_activation] %>
  def activate
    @<%= file_name %> = self.current_user = <%= class_name %>.find_and_activate!(params[:activation_code])
    flash[:notice] = "Your account has been activated!" 
    redirect_back_or_default('/')
    rescue User::ActivationCodeNotFound
      flash[:notice] = 'Activation code not found.'
      redirect_to activate_path
    rescue User::AlreadyActivated
      flash[:notice] = 'Your account has already been activated. You can log in below.'
      redirect_to login_path
    rescue ArgumentError
    	flash[:notice] = 'You must enter an activation code'
  end
<% end %>
end
